package org.example.bookingsystem.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.example.bookingsystem.model.Order;
import org.example.bookingsystem.model.Result;
import org.example.bookingsystem.model.Ticket;
import org.example.bookingsystem.service.SystemService;
import org.example.bookingsystem.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system")
public class SystemController {
    @Autowired
    private SystemService systemService;
    @RequestMapping("/getInfo")
    public List<Ticket> selectAllTickets(){
        return systemService.selectAllTickets();
    }
    @RequestMapping("/getOrder")
    public List<Order> selectAllOrders(HttpServletRequest request){
        String token = request.getHeader("user_token");
        int uid = JwtUtils.getUserIdFromToken(token);
        return systemService.selectOrder(uid);
    }
}
